package com.dong.order.api.config;

import com.aliyun.openservices.ons.api.bean.ConsumerBean;
import com.aliyun.openservices.ons.api.bean.ProducerBean;
import com.dong.common.mq.MqService;
import com.dong.order.api.mq.PolicyConsumerMessageListener;
import com.dong.order.api.mq.config.PolicyConsumerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author zhaodongchao
 * @date 2020/11/19 17:40
 */
@Configuration
public class MQConfig {
    @Resource
    private MqService mqService ;

    @Bean(name = "policyConsumer",initMethod = "start" ,destroyMethod = "shutdown")
    public ConsumerBean policyConsumerBean(PolicyConsumerConfig config){
        return mqService.createConsumer(config,new PolicyConsumerMessageListener());
    }

}
